package com.tencent.wxpay.demo.service.impl;

import com.tencent.wxpay.WXPay;
import com.tencent.wxpay.demo.listener.ResultListener;
import com.tencent.wxpay.demo.service.RefundQueryService;
import com.tencent.wxpay.demo.util.TestUtil;
import com.tencent.wxpay.protocol.request.RefundQueryReqData;
import com.tencent.wxpay.protocol.response.RefundQueryResData;
import org.springframework.stereotype.Service;

@Service
public class RefundQueryServiceImpl implements RefundQueryService {

    @Override
    public RefundQueryResData doRefundQuery(String outTradeNo) {
        try{
            RefundQueryReqData refundQueryReqData = new RefundQueryReqData(null,outTradeNo,null,null);
            RefundQueryResData refundQueryResData = WXPay.doRefundQueryBusiness(refundQueryReqData,new ResultListener<RefundQueryResData>());
            return refundQueryResData;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        if(TestUtil.init()){
            try{
                RefundQueryService refundQueryService = new RefundQueryServiceImpl();
                RefundQueryResData refundQueryResData = refundQueryService.doRefundQuery("20161014112011");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
